<!DOCTYPE html>
<!--[if IE 9]>         <html class="no-js lt-ie10" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
    <meta charset="utf-8">

    <title>数字币对冲平台|BDS虚拟币对冲平台</title>
    <#include "../static/top.ftl" >

        </head>
<body>
<!-- Page Wrapper -->
<!-- In the PHP version you can set the following options from inc/config file -->
<!--
    Available classes:

    'page-loading'      enables page preloader
-->
<div id="page-wrapper" class="page-loading">
    <!-- Preloader -->
    <!-- Preloader functionality (initialized in js/app.js) - pageLoading() -->
    <!-- Used only if page preloader enabled from inc/config (PHP version) or the class 'page-loading' is added in #page-wrapper element (HTML version) -->
    <div class="preloader">
        <div class="inner">
            <!-- Animation spinner for all modern browsers -->
            <div class="preloader-spinner themed-background hidden-lt-ie10"></div>

            <!-- Text for IE9 -->
            <h3 class="text-primary visible-lt-ie10"><strong>Loading..</strong></h3>
        </div>
    </div>

    <div id="page-container" class="header-fixed-top sidebar-visible-lg-full sidebar-light">
        <!-- Alternative Sidebar -->

        <!-- END Alternative Sidebar -->

        <!-- Main Sidebar -->



        <#include "../static/menu.ftl" >


            <!-- END Main Sidebar -->

            <!-- Main Container -->
            <div id="main-container">
                <!-- Header -->



                <#include "../static/header.ftl" >
                    <!-- END Header -->

                    <!-- Page content -->
                    <div id="page-content">
                        <!-- Validation Header -->
                        <div class="content-header">
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="header-section">
                                        <h1>资产情况</h1>
                                    </div>
                                </div>
                                <div class="col-sm-6 hidden-xs">
                                    <div class="header-section">
                                        <ul class="breadcrumb breadcrumb-top">
                                            <li>User Interface</li>
                                            <li>Forms</li>
                                            <li><a href="">Validation</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- END Validation Header -->
                        <!-- Table Styles Block -->
                        <div class="block">
                                    <!-- Table Styles Title -->
                                    <div class="block-title clearfix">
                                        <h2><span class="hidden-xs">按交易所</span> 统计</h2>
                                        <button type="button" id="btn_load" class="btn btn-effect-ripple btn-primary" style="float: right;">实时获取</button>
                                    </div>
                                    <!-- END Table Styles Title -->

                                    <!-- Table Styles Content -->
                                    <div class="table-responsive">
                                        <table id="general-table" class="table table-striped table-bordered table-vcenter">
                                            <thead>
                                                <tr>
                                                    <th>交易所</th>
                                                    <th>币种</th>
                                                    <th>价格/美元</th>
                                                    <th>可用数量</th>
                                                    <th>冻结数量</th>
                                                    <th>可用金额/美元</th>
                                                    <#--<th>冻结金额/美元</th>-->
                                                    <th>可用金额/人民币</th>
                                                    <#--<th>冻结金额/人民币</th>-->
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <#if accountInfoDto??>
                                                    <#if accountInfoDto.accountInfos??>
                                                        <#--所有交易所的资产情况(按交易所统计)-->
                                                        <#list accountInfoDto.accountInfos as info>
                                                            <#if info.assetList??>
                                                                <#list info.assetList as asset>
                                                                    <tr>
                                                                        <td>${info.exchange}</td>
                                                                        <td>${asset.currency}</td>
                                                                        <td>${asset.last_price!"0.000"}</td>
                                                                        <td>${asset.count!"0.000"}</td>
                                                                        <td>${asset.freez_count!"0.000"}</td>
                                                                        <td>${asset.amount!"0.000"}</td>
                                                                        <#--<td>${asset.freez!"0.000"}</td>-->
                                                                        <td>${asset.amount_cny!"0.000"}</td>
                                                                    </tr>
                                                                </#list>
                                                            </#if>
                                                        </#list>
                                                    </#if>
                                                <#else><tr><td colspan="6">${msg}</td></tr>
                                                </#if>
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- END Table Styles Content -->
                                </div>
                        <!-- END Table Styles Block -->

                        <!-- Table Styles Block -->
                        <div class="block">
                                    <!-- Table Styles Title -->
                                    <div class="block-title clearfix">
                                        <h2><span class="hidden-xs">按币种</span> 统计</h2>
                                    </div>
                                    <!-- END Table Styles Title -->

                                    <!-- Table Styles Content -->
                                    <div class="table-responsive">
                                        <table id="general-table" class="table table-striped table-bordered table-vcenter">
                                            <thead>
                                                <tr>
                                                    <th>币种</th>
                                                    <th>可用数量</th>
                                                    <th>冻结数量</th>
                                                    <th>可用总金额/美元</th>
                                                    <th>可用总金额/人民币</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <#if accountInfoDto??>
                                                    <#if accountInfoDto.accountInfos??>
                                                    <#--所有交易所的资产情况(按交易所统计)-->
                                                        <#list accountInfoDto.assetAccountList as asset>
                                                            <tr>
                                                                <td>${asset.currency}</td>
                                                                <td>${asset.count!"0.000"}</td>
                                                                <td>${asset.freez_count!"0.000"}</td>
                                                                <td>${asset.amount!"0.000"}</td>
                                                                <td>${asset.amount_cny!"0.000"}</td>
                                                            </tr>
                                                        </#list>
                                                        <tr><td colspan="5"><span style="float: right;">总计：$${accountInfoDto.amountSum!"0.000"}&nbsp;(约合人民币：${accountInfoDto.amountSumCny!"0.000"})</span></td></tr>
                                                    </#if>
                                                    <#else><tr><td colspan="4">${msg}</td></tr>
                                                </#if>
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- END Table Styles Content -->
                                </div>
                        <!-- END Table Styles Block -->
                    </div>
                    <!-- END Page Container -->
            </div>
            <!-- END Page Wrapper -->


        <!-- Load and execute javascript code used only in this page -->
        <script src="/res/js/pages/uiTables.js"></script>
        <script>$(function(){ UiTables.init(); });</script>
</body>
<script type="text/javascript">
    $(function () {
        $("#btn_load").click(function () {
            $("#btn_load").attr("disabled",true)
            $.ajax({
                url: "/account/get_accet_info",
                data: null,
                cache: false,
                type: "GET",
                dataType: 'jsonp',
                jsonp: "jsonpCallback",
                //其中success_jsonpCallback为自定义名称，与后台保持一致即可
                jsonpCallback: "success_jsonpCallback",
                success: function (result) {
                    if(200==result.code) {
                        window.location.href="/account/asset_info"
                    }else{
                        alert(result.msg)
                    }
                }
            });
        })
    });
//        $("#assets").empty()
//        var exchange=$("#select_exchange").val();
//        var url="/account/get_accet_info"
//        var args={"exchange":exchange}
//        $.ajax({
//            url: url,
//            data: args,
//            cache: false,
//            type: "GET",
//            dataType: 'jsonp',
//            jsonp: "jsonpCallback",
//            //其中success_jsonpCallback为自定义名称，与后台保持一致即可
//            jsonpCallback: "success_jsonpCallback",
//            success: function (result) {
//                alert(JSON.stringify(result))
//                if("suc"==result.code) {
//                    var info=result.data;
//                    var amountSum=info.amountSum;
//                    var freezSum=info.freezSum;
//                    $("span#amount_sum").empty()
//                    $("span#freez_sum").empty()
//                    $("span#amount_sum").append("<strong>总金额："+amountSum+"</strong>");
//                    $("span#freez_sum").append("<strong>冻结总金额："+freezSum+"</strong>");
//                    var assets=info.assetList;
//                    var html=""
//                    for(var i=0;i<assets.length;i++){
//                        var asset=assets[i]
//                        html+=add_assets(exchange,asset)
//                    }
//                    if(html==""){
//                        html="<tr>你在该交易所没有任何币种！</tr>"
//                    }
//
//                    $("#assets").append(html)
//                }else{
//                    alert(result.msg)
//                }
//            }
//        });
//    });
//
//    function add_assets(exchange,asset){
//        return "<tr><td><strong>"+exchange+"</strong></td>"+
//            "<td><strong>"+asset.currency+"</strong></td>"+
//            "<td><strong>"+asset.amount+"</strong></td>"+
//            "<td><strong>"+asset.freez+"</strong></td></tr>"
//    }

</script>
</html>